
*********************************************************************************************;

/* 						 This file reproduce Panel D of Table 10							*/

*********************************************************************************************;

libname rep "C:\Users\~";

data regbase; set rep.mydata; run;

option missing = " ";
%macro print;
data N; set N; Estimate = nValue1; if Label1 = "Used"; run;
data Nobs; set N; Parameter = "N"; keep EstType Parameter Estimate; run;
data r2; set fit; Parameter = "RSQ"; keep EstType Parameter RSquare; rename RSquare = Estimate;  run;
data final; set parest Nobs r2 ; drop EstType StdErr Probt DF; run;
data final&i; set final; rename Estimate = &type._&freq tValue = t_&type._&freq; 
if Parameter not in ("h_freq", "a_freq", "N", "RSQ") then delete; run;
%mend;

%macro decomp ;

%do j=1 %to 2;

%if &j =1 %then %do; %let type = unlev; %end; 
%else %do; %let type = lev; %end;

%do i=1 %to 2;
%if &i =1 %then %do; %let freq = low; %let con = high; %end; 
%else %do; %let freq = high; %let con = low; %end;
ods output "Nonlinear GMM Summary of Residual Errors" = fit;
ods output "Nonlinear GMM Parameter Estimates" = parest;
ods output "Estimation Summary Statistics" = N;
proc model data=regbase plot =none;
endo &type._syy_&freq ; exog active_low active_high &type._low &type._high mktrf amihud tover hml smb; ; instruments _exog_;
&type._syy_&freq =b0 + h_freq * &type._&freq +h_con * &type._&con + a_freq *active_&freq + a_con *active_&con +b1*mktrf +b2*amihud +b3*tover +b4*hml +b5*smb; ;
fit &type._syy_&freq / gmm kernel=(bart,13,0) vardef=n; run; quit; 
%print;
%end;

data &type; merge final1 final2; run;
%end;
data T10D; merge unlev lev; run;

%mend;

%decomp ;

proc print data = T10D noobs; run;
